package com.moore.service.Impl;

import com.moore.bean.Message;
import com.moore.dto.ResponseData;
import com.moore.mapper.MessageMapper;
import com.moore.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.moore.utils.Logger.toLog;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public ResponseData getMessage(String tenant,String status) {
        List<Message> messages = messageMapper.getMessageByTenant(tenant,status);
        toLog("获取消息成功");
        return new ResponseData(200,"获取成功",messages,messages.size());
    }

    @Override
    public ResponseData isRead(String status, long id) {
        int result = messageMapper.isRead(status,id);
        toLog("消息已读");
        return new ResponseData(200,"消息已读",null,result);
    }
}
